﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharedComponents;

namespace OurLeague.Object
{
    public class Referee : Person
    {
        #region Fields

        public static List<Referee> Referees = new List<Referee>();

        #endregion

        #region Constructors

        public Referee() : base() { }
        public Referee(Person person) : base(person) { }

        #endregion

        #region Public Methods
        #endregion

        #region Properties
        #endregion

        #region Static methods

        public new static Referee load(String idReferee)
        {
            Referee referee = Referees.Count > 0 ? Referees.Find(r => r.Id == idReferee) : null;
            
            if (referee == null)
            {
                Person person = Person.load(idReferee);
                referee = new Referee(person);
                Persons[Persons.FindIndex(P => P.Id == person.Id)] = referee;

                Referees.Add(referee);
            }

            return referee;
        }

        #endregion
    }
}
